// pages/productionManage/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    tableList: [1, 2, 3],
    procurementData:[],
    procurementState:'0',
    sailData:[],
    sailState:'0',
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.getProcurementList()
    this.getSailList()
  },
  /**
   * 采购订单列表
   */
  getProcurementList(){
    let that=this
    wx.$req({
      url: '/wms/orderPurchase/list?page=0&size=2',
      method:'POST',
      data:{orderState:this.data.procurementState},
      loadingText: '加载中...'
    }).then(res => {
        let procurementData=res.data.content
        that.setData({
          procurementData: procurementData 
        })
      })
  },
  // 采购订单状态切换
  changePro(e){
    let state=e.currentTarget.dataset.state;
    if(this.data.procurementState!=state){
      this.setData({
        procurementState: state 
      })
      this.getProcurementList()
    }
  },
/**
   * 采购采购列表
   */
  getSailList(){
    let that=this
    wx.$req({
      url: '/wms/orderSail/list?page=0&size=2',
      method:'POST',
      data:{orderState:this.data.sailState},
      loadingText: '加载中...'
    }).then(res => {
        let sailData=res.data.content
        that.setData({ sailData  })
      })
  },
  // 销售订单状态切换
  changeSail(e){
    let state=e.currentTarget.dataset.state;
    if(this.data.sailState!=state){
      this.setData({
        sailState: state 
      })
      this.getSailList()
    }
  },
  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },
  // 跳转采购订单列表页
  toDetail () {
    wx.navigateTo({
      url: '/pages/orderDetail/index'
    })
  },
  // 跳转销售订单列表页
  toSailDetail(){
    wx.navigateTo({
      url: '/pages/SailorderDetail/index'
    })
  },
  // 跳转交易流水页
  toBill (e) {
    wx.navigateTo({
      url: '/pages/billWater/index',
    })
  },
  // 跳转采购订单详情
  toProInfo (e) {
    let item=e.currentTarget.dataset.item
    wx.navigateTo({
      url: '/pages/productOrderInfo/index?id='+item.id
    })
  },
  // 跳转销售订单详情
  toSailInfo (e) {
    let item=e.currentTarget.dataset.item
    wx.navigateTo({
      url: '/pages/sailOrderInfo/index?id='+item.id
    })
  }

})